﻿using LiteDB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestingApp.Services {
    public class Repository  {
        private readonly LiteDatabase _database;

        public Repository(LiteDatabase database)   {
            _database = database;
        }


        public void Save<T>(T item) {
            GetCollection<T>().Upsert(item);                
        }

        public IEnumerable<T> FindAll<T>()   {
            return GetCollection<T>().FindAll();
        }


        private ILiteCollection<T> GetCollection<T>() {
            return _database.GetCollection<T>();
        }

       
    }
}
